<?php
class HotelFacility extends HotelFacilityPeer
{
	function HotelFacility()
	{
		parent::HotelFacilityPeer();
	}
	
	
	public static function getAllFacilitiesForHotel($hotel_id)
	{
		$db = new Database();
		$query = "SELECT facility_id FROM hotel_facility WHERE hotel_id = ".$hotel_id;
		$db->query($query);
		$ids = $db->fetch_array($db->result);
		$facilities = array();
		if ($ids)
			foreach ($ids as $id) {
				$facility = new Facility();
				$facility->select($id['facility_id']);
				$facilities[] = $facility;
			}
			
		return $facilities;
	}
	
	
	public static function retriveByHotelIdAndFacilityId($hotel_id, $facility_id)
	{
		$db = new Database();
		$query = "SELECT id FROM hotel_facility WHERE hotel_id = $hotel_id AND facility_id = $facility_id";
		$db->query($query);
		$id = $db->result;
		$id = mysql_fetch_row($id);
		if (isset($id[0])) {
			$id = $id[0];
			$hotel_facility = new HotelFacility();
			$hotel_facility->select($id);
			return $hotel_facility;
		}
		return null;
	}
}
?>